<!DOCTYPE html>
<html>
	<head>
		<title>这是一个按钮</title>
		<meta charset="utf-8">
		<script type="text/javascript">
			function myfunction() {
				var x = document.getElementById('demo').value;
				if (isNAN(x) || x.replace(/(^\s*)|(\s*$)/g ,"") == "") {
					//isNaN(x)||x.replace(/(^\s*)|(\s*$)/g,"")=="" --√
					//isNAN(x) || x.replace(/(^\s*)|(\s*$)/g ,"") == "" --X
					alert("不是数字");
				}
			}
		</script>
	</head>
	<body>
		<h1>第一段</h1>
		<p>请输入数字，如果不是，浏览器会弹出提示框</p>
		<input type="text" id="demo" value="">
		<input type="button" onclick="myfunction()" value="点击">
	</body>
</html>
